package postgress

import (
	"github.com/pkg/errors"
	"github.com/spf13/viper"
	"go.uber.org/zap"
)

/*
"Debug": true,
    "MaxConn": 50,
    "Driver": "postgres",
    "Source": "host=10.0.10.18 port=30000 user=postgres dbname=postgres sslmode=disable"
*/

type Options struct {
}

func NewOptions(v *viper.Viper, logger *zap.Logger) (*Options, error) {
	var (
		err error
		o   = new(Options)
	)
	if err = v.UnmarshalKey("postgres", o); err != nil {
		return nil, errors.Wrap(err, "unmarshal postgres option error")
	}

	logger.Info("load postgres options success", zap.Any("postgres options", o))
	return o, err
}
